package models

import (
	"time"
	"xorm.io/builder"
)

type CoachLoginlog struct {
	Id             int       `xorm:"not null pk autoincr INT(11)"`
	Coachnumber    string    `xorm:"index VARCHAR(45)"`
	Coachid        string    `xorm:"VARCHAR(45)"`
	Canteach       string    `xorm:"VARCHAR(45)"`
	Datetimelogin  time.Time `xorm:"DATETIME"`
	Datetimelogout time.Time `xorm:"DATETIME"`
	Imglogin       string    `xorm:"VARCHAR(255)"`
	Imglogout      string    `xorm:"VARCHAR(255)"`
	Sim            string    `xorm:"VARCHAR(45)"`
	Mongoid        string    `xorm:"comment('登录记录在mongodb中的objectID') index VARCHAR(24)"`
}

func (c *CoachLoginlog) GetById(id string) (list CoachLoginlog, err error) {
	_, err = engine.Table("dts_coach_loginlog").ID(id).Get(&list)
	return list, err
}

func (c *CoachLoginlog) GetList(filter builder.Cond) (list *CoachLoginlog, err error) {
	list = new(CoachLoginlog)
	_, err = engine.Table("dts_coach_loginlog").And(filter).Desc("id").Limit(1).Get(list)
	return list, err
}
